<?php
require_once('Zend/Date.php');

require_once('Extension/View/Helper/Abstract.php');

class Extension_View_Helper_D extends Extension_View_Helper_Abstract
{
    public function D($dateString     = null, 
                      $showTime       = false, 
                      $dateFormat     = Zend_Date::DATE_FULL,
                      $inputFormat    = Zend_Date::ISO_8601, 
                      $timeFormat     = Zend_Date::TIMES)
    {
        $result = '';
        
        $date = Kbs::initDate();

        if (null !== $dateString and !empty($dateString)) {
            if (false == Zend_Date::isDate($dateString, $inputFormat)) {
                //throw new Zend_Date_Exception($dateString . ' is not a correct date !');
            }

            $date->set($dateString, $inputFormat);
        }

        $result = $date->get($dateFormat);

        if ($showTime) {
            $t = $date->get($timeFormat);
            $result .= ' ' . $t;
        }

        //$city = Extension_Date_Cities::City('Beijing', 'nautic');
        //print_r($date->getSunset($city)->get(Zend_Date::ISO_8601));

        if ($date->compare(19, Zend_Date::HOUR) >= 0) {
            $result .= 'home home !';
        }

        return $result;
    }
}